package com.example.ayniu.treadmill.adapter;


import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import com.example.ayniu.treadmill.fragment.Fragment_main;
import com.example.ayniu.treadmill.fragment.Fragment_class;
import com.example.ayniu.treadmill.fragment.Fragment_set;
import com.example.ayniu.treadmill.MainActivity;

/**
 * Created by Ayniu on 2016/9/5.
 */
public class MyPagerAdapter extends FragmentPagerAdapter {

    private final int PAGER_COUNT = 3;
    private Fragment_main mFragment_main = null;
    private Fragment_class mFragment_class = null;
    private Fragment_set mFragment_set = null;

    public MyPagerAdapter(FragmentManager fm){
        super(fm);
        mFragment_main = new Fragment_main();
        mFragment_class = new Fragment_class();
        mFragment_set = new Fragment_set();
    }


    @Override
    public Fragment getItem(int index) {
        Fragment fragment = null;
        switch (index) {
            case MainActivity.PAGE_ONE:
                fragment = mFragment_main;
                break;
            case MainActivity.PAGE_TWO:
                fragment = mFragment_class;
                break;
            case MainActivity.PAGE_THREE:
                fragment = mFragment_set;
                break;
        }
        return fragment;
    }

    @Override
    public int getCount() {
        return PAGER_COUNT;
    }

    @Override
    public Object instantiateItem(ViewGroup vg, int position) {
        return super.instantiateItem(vg, position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        super.destroyItem(container, position, object);
    }
}